package parser

import (
	"github.com/hashicorp/hcl/v2"
	"github.com/ihaiker/tfwrapper/internal/config"
	"github.com/ihaiker/tfwrapper/internal/eval"
)

func parseTerraform(options config.Running, file *hcl.File) (*config.Terraform, hcl.Diagnostics) {
	ctx, diags := eval.CreateEvalContext(options)
	if diags.HasErrors() {
		return nil, diags
	}
	terraform := new(config.Terraform)
	diags = ctx.PartialUniqueBlock(file.Body, "terraform", terraform)
	return terraform, diags
}
